
using Unity.Mathematics;
namespace Geometry
{
    public class Plane
    {
        public double3 Normal { get; set; }
        public double Distance { get; set; }

        public Plane(double3 normal, double distance)
        {
            this.Normal = normal;
            this.Distance = distance;
        }

        public Plane(double3 point, double3 normal) : this(normal, -(math.dot(normal, point)))
        {

        }
        public double getPointDistance(double3 point)
        {
            return math.dot(this.Normal, point) + this.Distance;
        }

        public double3 projectPointOntoPlane(double3 point)
        {
            double pointDistance = this.getPointDistance(point);
            double3 scaledNormal = this.Normal * pointDistance;
            return point - scaledNormal;
        }
    }
}